<?php
include "../include/global.php";
include "../include/admin_check.php";
include "../../FCKeditor/fckeditor.php";
$xtpl = new XTemplate ("hotelWrite.htm");
include "setting.php";
//
include "../include/function.php";
$xtpl->assign("left_panel", left_panel());
$xtpl->assign("header_panel", header_panel());
$xtpl->assign("footer_panel", footer_panel());

// ++ lang
if($lang=='v'){
	$xtpl->assign('type_vietnamese', 'onkeyup="initTyper(this)"');
}
$xtpl->assign("title", hotel);
$xtpl->assign("lbl_search", Search);
$xtpl->assign("lbl_no", No);
$xtpl->assign("lbl_country", Country);
$xtpl->assign("lbl_city", City);
$xtpl->assign("lbl_name", Name);
$xtpl->assign("lbl_price", Price);
$xtpl->assign("lbl_brief", Brief);
$xtpl->assign("lbl_overview", Overview);
$xtpl->assign("lbl_indepth", Indepth);
$xtpl->assign("lbl_location", Location);
$xtpl->assign("lbl_traveladvice", TravelAdvice);
$xtpl->assign("lbl_rates", Rates);
$xtpl->assign("lbl_image", Image);
$xtpl->assign("lbl_position", Position);
$xtpl->assign("lbl_active", Active);
$xtpl->assign("lbl_ishome", IsHome);
$xtpl->assign("lbl_isdestination", IsDestination);
$xtpl->assign("lbl_metadescription", MetaDescription);
$xtpl->assign("lbl_metakeyword", MetaKeyword);
$xtpl->assign("lbl_save", Save);
$xtpl->assign("lbl_save_add", SaveAdd);
$xtpl->assign("lbl_cancel", Cancel);
// -- lang

$ID=intval($_GET['ID']);
if($ID){
	$sql="select * from ".pre_table."hotel where hotel_id='$ID'";
	$row=recordset($sql);
	$country_id=$row['country_id'];
	$city_id=$row['city_id'];
	$hotel_name=$row['hotel_name'];	
	$hotel_price=$row['hotel_price'];	
	$hotel_brief=$row['hotel_brief'];
	$hotel_overview=$row['hotel_overview'];	
	$hotel_indepth=$row['hotel_indepth'];	
	$hotel_location=$row['hotel_location'];	
	$hotel_traveladvice=$row['hotel_traveladvice'];	
	$hotel_rates=$row['hotel_rates'];	
	$hotel_position=$row['hotel_position'];	
	$hotel_ishome=$row['hotel_ishome'];	
	$hotel_isdestination=$row['hotel_isdestination'];	
	$hotel_isactive=$row['hotel_isactive'];	
	$hotel_metadescription=$row['hotel_metadescription'];	
	$hotel_metakeyword=$row['hotel_metakeyword'];	
	$old_hotel_image=$row['hotel_image'];
		
	if($row[hotel_ishome]==1) $ChkHome = "checked";			
	if($row[hotel_isdestination]==1) $ChkDestination = "checked";			
	if($row[hotel_isactive]==1) $ChkActive = "checked";			
	
	$xtpl->assign("hotel_name", $hotel_name);
	$xtpl->assign("hotel_price", $hotel_price);
	$xtpl->assign("hotel_brief", $hotel_brief);
	$xtpl->assign("old_hotel_image", $old_hotel_image);
	$xtpl->assign("hotel_position", $hotel_position);
	$xtpl->assign("hotel_ishome", $hotel_ishome);
	$xtpl->assign("hotel_isdestination", $hotel_isdestination);
	$xtpl->assign("hotel_isactive", $hotel_isactive);
	$xtpl->assign("hotel_metadescription", $hotel_metadescription);
	$xtpl->assign("hotel_metakeyword", $hotel_metakeyword);
	$xtpl->assign("ChkHome", $ChkHome);
	$xtpl->assign("ChkPagehotel", $ChkPagehotel);
	$xtpl->assign("ChkDestination", $ChkDestination);
	$xtpl->assign("ChkActive", $ChkActive);
	$xtpl->assign("id", $ID);

	$xtpl->assign("type", "EDIT");	
}else{
	// ++ set position
	$stsql = "SELECT hotel_id from ".pre_table."hotel WHERE lang='".$lang."'";
	$rssql = execSQL($stsql);
	$numrec=mysql_num_rows($rssql);
	$hotel_position=$numrec+1;
	$xtpl->assign("hotel_position", $hotel_position);
	// -- set position
	
	$xtpl->assign("type", "ADD");	
	$xtpl->assign("ChkActive", "checked");
}

$xtpl->assign("cbo_country", cbo_country($country_id));
$xtpl->assign("cbo_city", cbo_city($country_id, $city_id));

// ++ image
if($old_hotel_image)
{
	$has_image='<img src='.$path.$old_hotel_image.' width="50" align="absmiddle" />&nbsp;&nbsp;<a href="javascript:del_image('.$ID.')">'.Delete.'</a>';
}
$xtpl->assign("has_image", $has_image);


$sBasePath="../../FCKeditor/"; 
$oFCKeditor = new FCKeditor('hotel_overview') ;
$oFCKeditor->BasePath	= $sBasePath ;
$oFCKeditor->Value		= $hotel_overview ;
$oFCKeditor->Width	= "100%" ;
$oFCKeditor->Height	= "300" ;

$oFCKeditor2 = new FCKeditor('hotel_indepth') ;
$oFCKeditor2->BasePath	= $sBasePath ;
$oFCKeditor2->Value		= $hotel_indepth ;
$oFCKeditor2->Width	= "100%" ;
$oFCKeditor2->Height	= "300" ;

$oFCKeditor3 = new FCKeditor('hotel_location') ;
$oFCKeditor3->BasePath	= $sBasePath ;
$oFCKeditor3->Value		= $hotel_location ;
$oFCKeditor3->Width	= "100%" ;
$oFCKeditor3->Height	= "300" ;

$oFCKeditor4 = new FCKeditor('hotel_traveladvice') ;
$oFCKeditor4->BasePath	= $sBasePath ;
$oFCKeditor4->Value		= $hotel_traveladvice ;
$oFCKeditor4->Width	= "100%" ;
$oFCKeditor4->Height	= "300" ;

$oFCKeditor5 = new FCKeditor('hotel_rates') ;
$oFCKeditor5->BasePath	= $sBasePath ;
$oFCKeditor5->Value		= $hotel_rates;
$oFCKeditor5->Width	= "100%" ;
$oFCKeditor5->Height	= "300" ;

//////////////////////////////////////
$xtpl->parse("MAIN");
eval("?".">".$xtpl->text("MAIN"));
?>